package com.hunter.api.mapper;

import java.util.List;

import com.alibaba.fastjson.JSONObject;

import com.hunter.api.bean.SqlConfigBean;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author HunterHuang
 * @version 1.0
 * @ClassName SqlMapper
 * @date 2019/5/30 10:12
 */
@Repository
public interface SqlMapper {


    @Select("${sql}")
    @Results()
    JSONObject queryRow(String sql);

    @Select("${sql}")
    @Results()
    List<JSONObject> queryAll(String sql);

    @Select("select count(1) from ( ${sql} ) as a")
    @Results()
    Object queryAllCount(String sql);

    @Select("${sql}")
    @Results()
    Object queryScalar(String sql);


    @Select("${sql}")
    Object insertData(String sql);

    @Update("${sql}")
    void updateData(String sql);


    @Select("SELECT *  FROM ab.sql " +
        "WHERE is_deleted = 0 and enabled = 1 and code = #{code} limit 1")
    @Results()
    SqlConfigBean SqlConfigInfo(SqlConfigBean sqlConfigBean);
}
